import responseValidate from '../responseValidate';

test('responseValidate', () => {
	expect(
		responseValidate({
			tid: 'dd6c929cf3c042acbdb4ccb587d58e63',
			resp_avg: 2572.53,
			type: 'HTTP',
			detail: [
				{
					ip: '104.24.107.95',
					connect_time: 2487.6,
					content_len: 15,
					header:
						'{"content-length": "15", "set-cookie": "__cfduid=d26dd875d53a909c075f7149adfadb6f11606128506; expires=Wed, 23-Dec-20 10:48:26 GMT; path=/; domain=.nkey.co; HttpOnly; SameSite=Lax", "cf-cache-status": "DYNAMIC", "nel": "%7B\\"report_to\\":\\"cf-nel\\",\\"max_age\\":604800%7D", "cf-request-id": "0696512f580000cdd3ba981000000001", "server": "cloudflare", "connection": "keep-alive", "report-to": "%7B\\"endpoints\\":%5B%7B\\"url\\":\\"https:%5C/%5C/a.nel.cloudflare.com%5C/report?s=tomFMYlQemNiES8xTSNmWo9Avh1yryQssdzTth%252BBzjl0L1AwbL5L516ZiR4ecWFdKTUOGdYIdPUayReCeDvmYefp%252BIZ862ol42Q3\\"%7D%5D,\\"group\\":\\"cf-nel\\",\\"max_age\\":604800%7D", "date": "Mon, 23 Nov 2020 10:48:27 GMT", "cf-ray": "5f6a515efa67cdd3-CDG"}',
					resp_time: 3314.88,
					download_speed: 0.24,
					inner_type: '',
					response_time: 787.12,
					match_key: {},
					ssl_shake_time: 0,
					area: '成都市移动',
					download_time: 0.06,
					has_error: false,
					status_code: 200,
					dns_time: 40.1,
				},
			],
		})
	).toEqual({
		type: 'HTTP',
		tid: 'dd6c929cf3c042acbdb4ccb587d58e63',
		respAvg: 2572.53,
		detail: [
			{
				node: 'chengdu-cmc',
				area: '成都市移动',
				ip: '104.24.107.95',
				respTime: 787.12,
				downloadTime: 0.06,
				downloadSpeed: 0.24,
				statusCode: 200,
				dnsTime: 40.1,
				connectTime: 2487.6,
				contentLength: 15,
				totalTime: 3314.88,
				inner_type: '',
				match_key: {},
				sslShakeTime: 0,
				has_error: false,
				response:
					'content-length: 15\n' +
					'set-cookie: __cfduid=d26dd875d53a909c075f7149adfadb6f11606128506; expires=Wed, 23-Dec-20 10:48:26 GMT; path=/; domain=.nkey.co; HttpOnly; SameSite=Lax\n' +
					'cf-cache-status: DYNAMIC\n' +
					'nel: %7B"report_to":"cf-nel","max_age":604800%7D\n' +
					'cf-request-id: 0696512f580000cdd3ba981000000001\n' +
					'server: cloudflare\n' +
					'connection: keep-alive\n' +
					'report-to: %7B"endpoints":%5B%7B"url":"https:%5C/%5C/a.nel.cloudflare.com%5C/report?s=tomFMYlQemNiES8xTSNmWo9Avh1yryQssdzTth%252BBzjl0L1AwbL5L516ZiR4ecWFdKTUOGdYIdPUayReCeDvmYefp%252BIZ862ol42Q3"%7D%5D,"group":"cf-nel","max_age":604800%7D\n' +
					'date: Mon, 23 Nov 2020 10:48:27 GMT\n' +
					'cf-ray: 5f6a515efa67cdd3-CDG',
			},
		],
	});
});
